import { Service } from '../util/axios'
const login = (data) => {
  return Service({
    url: `aboutLogin/login`,
    method: 'POST',
    data
  })
}

const register = (data) => {
  return Service({
    url: 'aboutLogin/register',
    method: 'POST',
    data
  })
}

const test = (data) => {
  return Service({
    url: '/test',
  })
}

const main = () => {
  return Service({
    url: '/main',
  })
}

const logout = (data) => {
  return Service({
    url: `aboutLogin/logout`
  })
}

const addRecord = (data) => {
  return Service({
    url: '/addSearchList',
    method: 'POST',
    data
  })
}

const searchRecordHistory = (data) => {
  return Service({
    url: '/querySearchRecord',
    method: 'POST',
    data
  })
}

/** 删除历史记录 */
const deleteSearchHistory = (username) => {
  return Service({
    url: `/deleteSearchHistory?username=${username}`
  })
}

/** 获取菜单列表的信息 */
const getMenu = () => {
  return Service({
    url: '/menu'
  })
}

/** 找回密码的第一步 */
const findPass = (data) => {
  return Service({
    url: `aboutLogin/findPass`,
    method: 'POST',
    data
  })
}

/** 修改密码 */
const changePass = (data) => {
  return Service({
    url: 'aboutLogin/changePass',
    method: 'POST',
    data
  })
}

/** 查询首页的其他数据 */
const queryOtherData = () => {
  return Service({
    url: '/otherData'
  })
}

/** 获取省市信息 */
const queryCityData = () => {
  return Service({
    url: '/changeCity/city'
  })
}

/** 更新城市的历史搜索 */
const cityRecord = (data) => {
  return Service({
    url: '/changeCity/addVisitCity',
    method: 'POST',
    data
  })
}

/** 查询城市的历史搜索 */
const queryCityRecord = () => {
  return Service({
    url: '/changeCity/getCityHistory'
  })
}

export default {
  login,
  register,
  test,
  main,
  logout,
  addRecord,
  searchRecordHistory,
  deleteSearchHistory,
  getMenu,
  findPass,
  changePass,
  queryOtherData,
  queryCityData,
  cityRecord,
  queryCityRecord
}